package threadDemo1.run_start;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-02-28
 * Time: 22:44
 */
public class ThreadDemo {
    public static void main1(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.run();

        for (int i = 0; i < 5; i++) {
            System.out.println("Hello Main");
            Thread.sleep(100);
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.start();

        for (int i = 0; i < 5; i++) {
            System.out.println("Hello Main");
            Thread.sleep(100);
        }
    }
}
